package net.muchine.test.strophe.web.controller;

import net.muchine.test.strophe.core.configuration.Configuration;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/home")
public class HomeController {
	private Log log = LogFactory.getLog(this.getClass());
	@Autowired Configuration config;
	
	@RequestMapping("/test")
	public String test(ModelMap model) {
		model.put("msg", "world");
		System.out.println("go test..." + model.get("msg"));
		
		return "/test";
	}
	 
	@RequestMapping("/login")
	public String login() {
		return "/login";
	}
	
	@RequestMapping("/peek")
	public String goPeek(ModelMap model) {
		model.put("config", this.config);
		return "/peek";
	}
	
	@RequestMapping("/arthur")
	public String goArthur() {
		return "/arthur";
	}
	
	@RequestMapping("/gab")
	public String goGab(ModelMap model) {
		model.put("config", this.config);
		return "/gab";
	}
	
	@RequestMapping("/dig")
	public String goDig(ModelMap model) {
		model.put("config", this.config);
		return "/dig";
	}
	
	@RequestMapping("/groupie")
	public String goGroupie(ModelMap model) {
		model.put("config", this.config);
		return "/groupie";
	}
	
	@RequestMapping("/sketchcast")
	public String goSketchCast(ModelMap model) {
		model.put("config", this.config);
		return "/sketchcast";
	}
	
	@RequestMapping("/netpad/host")
	public String goNetPadHost(ModelMap model) {
		model.put("config", this.config);
		return "/netpad-host";
	}
	
	@RequestMapping("/netpad/client")
	public String goNetPadClient(ModelMap model) {
		model.put("config", this.config);
		return "/netpad-client";
	}
	
	@RequestMapping("/toetem/referee")
	public String goToetemReferee(ModelMap model) {
		model.put("config", this.config);
		return "/toetem/referee";
	}
	
	@RequestMapping("/toetem/client")
	public String goToetemClient(
			  @RequestParam(required = false) String id
			, ModelMap model) {
		if (id == null) id = "sejoonlim";
		log.info("jid: " + id);
		
		model.put("id", id);
		model.put("config", this.config);
		
		
		return "/toetem/client";
	}
}
